package com.gonsin.gview.model.form;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.gonsin.gview.model.GFormItemModel;
import com.gonsin.gview.model.data.GListDataModel;
import com.gonsin.i18n.logic.T;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@ApiModel("下拉选择框")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class GMultiSelectorModel extends GFormItemModel {

    @ApiModelProperty("selector表示下拉框，还有check_box\\file\\radio\\rich_text\\text_input\\tree_check_box\\tree_selector")
    private String itemType;

    @ApiModelProperty("是否必选")
    private boolean required;

    @ApiModelProperty("查询或者提交表单时，表示  ${keyName}=value")
    private String keyName;

    @ApiModelProperty("显示的名字")
    private String name;

    @ApiModelProperty("根据情况显示")
    private String showIf;

    @ApiModelProperty("根据情况禁用")
    private String disableIf;

//    @Deprecated
//    @ApiModelProperty("下拉的内容")
//    private List<KeyValue> values;

    @ApiModelProperty("数据获取相关")
    private GListDataModel listData;

    @ApiModelProperty("当单个表单项被修改时，触发对应的action事件")
    private String buttonId;

    @Override
    public GFormItemModel tClone() {
        GMultiSelectorModel model = new GMultiSelectorModel();
        BeanUtil.copyProperties(this, model, CopyOptions.create().setIgnoreNullValue(true));
        if(name != null){
            model.setName(T.t(name));
        }
//        model.setPlaceholder(T.t(placeholder));
        return model;
    }

}
